from Tkinter import *
from wrappers import *

class ToolPallette():
	title = 'Tools'
	currentTool = 'design'
	
	def launch(self, root):
		self.windowRoot = Toplevel(root)
		self.windowRoot.title(self.title)
		self.windowRoot.iconname(self.title)
		self.windowRoot.resizable(0,0)
		self.windowRoot.wm_attributes("-toolwindow", 1)
	
	def setTool(self, strNewTool):
		colorSelected = '#888888'
		colorBlank = '#ece9d8'
		for strTool in self.dictButtons:
			self.dictButtons[strTool].config(bg=colorBlank)
		self.dictButtons[strNewTool].config(bg=colorSelected)
		self.currentTool = strNewTool
		
	def draw_form(self):
		frTop = Frame(self.windowRoot)
		frBottom = Frame(self.windowRoot)
		frTop.pack(fill=BOTH, expand=1)
		frBottom.pack(fill=BOTH, expand=1)
		
		topTools = [
		('design','R0lGODlhGAAYAIABAAAAAP///yH5BAEAAAEALAAAAAAYABgAAAI0jI+py+0PAXxATlbtTVlv03lbKE5kSZ3fWY0surxtRH5BduMuqF9eZzsAg7xZcEg0EpebAgA7'),
		('script','R0lGODlhGAAYAKIHAAAAAElJSSwsLENDQ2RkZDQ0NF1dXf///yH5BAEAAAcALAAAAAAYABgAAANPeLrc/jDKSatd4MKsTeOLJw0BAx7BQAmlAgaCxboKrM2ZrR0FARCFCmBILBqHld4vuMOhYpfZgaNbtaaLaoRkYqQmIkwjbDntaOe0es1IAAA7'),
		('run','R0lGODlhGAAYAJECAP///wAAAP///wAAACH5BAEAAAIALAAAAAAYABgAAAJOlI+pixEMGwAvwjCrXZhu1mmfRDkjGZpjmGXi1VLtezgPK+e0kE6+H+IAf8QMKFYEwjpJ47H529WgShhVSmpip9Att+j9EsMGm9l2OhUAADs='),
		]
		self.dictButtons = {}
		self.images = {} #store images in memory
		i=0
		for tool in topTools:
			im = PhotoImage(format='gif',data=tool[1])
			self.images[tool[0]] = im #store images in memory
			
			b = Button(frTop, image=im, command=Callable(self.setTool,tool[0]))
			b.grid(row=0,column=i)
			self.dictButtons[tool[0]] = b
			i+=1
		
		moreTools = [
		('button','R0lGODlhGAAYALMJAOLi4lhYWOrq6pWVlZSUlOnp6ePj41lZWf///////wAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAkALAAAAAAYABgAAARYMMlJq7046827/2AoJkAplChqlEhwrUBRwqhgE65Vp3w55JWdbSgoFGy/C+DU6yV1zGYKp5RJp0DK8joDUHWEgXhAKI/D5OwkwA4c2uy3uz2q2+/4vD4UAQA7'),
		('label','R0lGODlhGAAYAJECAP///wAAAP///wAAACH5BAEAAAIALAAAAAAYABgAAAIxlI+py+0Po5y02osd2Lx3vQWAGH4NJ5KjyaAjmW7gGqvAnMLrfXq+nAkKh8Si8SgoAAA7'),
		('input','R0lGODlhGAAYAJECAP///wAAAP///wAAACH5BAEAAAIALAAAAAAYABgAAAI2lI+py+0Po5y02otZ2Lz7ngTASJbmGISoCLAnqrKi+6bIzLUvaR8zqtu1Qp+iJ4NMKpfMZrMAADs='),
		('field','R0lGODlhGAAYAJEDAAAAAP///+zs7P///yH5BAEAAAMALAAAAAAYABgAAAI5nI+py+0Po5y02gGy3jwvEITiKILAR6ah9nWuqQigSsLKTJfBeb/djsqVPDehjpfwvS7MpvMJjVYKADs='),
		('image','R0lGODlhGAAYAOZJAAAAAPPz8/Ly8u/v7/Hx8e3t7YeHh7Ozs9vb28zMzLCwsNnZ2ZeXl62trefn56WlpcrKyqOjo729vaGhoZiYmLm5uY2NjZ+fn8/Pz7+/v+vr69bW1u7u7sjIyNLS0oaGhsTExOnp6dDQ0MHBwbu7u6+vr4+Pj46OjpCQkKenp8DAwLy8vLi4uOjo6JOTk5GRkZubm6mpqfDw8OHh4eXl5a6urtfX18XFxYmJiYqKitPT052dnaurq93d3eTk5OLi4pqamubm5t/f35WVlezs7JKSkra2toiIiIuLi////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAEkALAAAAAAYABgAAAengEmCg4SFhoeIiYqLjI2Oj4cAkpJJk5SLkgEDDpMHDxSXiJICmg4IABkKEQwnoYYABaQFNAsJEiUTQxYGAIkAHLI+NhAkDRcuSLy+AwEERD8bHRU8O0U5H72izAQaMzo3LDEwLzjKogACBCFCHiBGKUAoR66vADItPSIjnhQm9JEAgiDAoEIVg3/nakmoMQGhLwAQVjRwqEhSBYqYMELayLGjx4+JAgEAOw=='),
		('choice','R0lGODlhGAAYAKIEAP///wAAAEFBQezs7P///wAAAAAAAAAAACH5BAEAAAQALAAAAAAYABgAAAM8SLrc/jDKSau9OOvtgv9g6D0BYJ5oGpBpi66dIM90DTNDUO/0zZQul28BDKpYxmMnqWyIniCOdEqtWikJADs='),
		('rectangle','R0lGODlhGAAYAJECAP///wAAAP///wAAACH5BAEAAAIALAAAAAAYABgAAAIvlI+py+0Po5y02ruC3ry3AITiKAYfiYYmA6bkmrnvKZd0DcBKx3PYDwwKh8QiowAAOw=='),
		('circle','R0lGODlhGAAYAJECAP///wAAAP///wAAACH5BAEAAAIALAAAAAAYABgAAAItlI+py+0Po5y02guDvhr4PQXe+IXkGEjiiUYrC6QuLM9s7b5gpeHYDwwKh5QCADs='),
		('line','R0lGODlhGAAYAIABAAAAAP///yH5BAEAAAEALAAAAAAYABgAAAIjjI+py+0Po5y0MmARwDns7nHZ15GjaJkpWqktS7ngTNf2LRUAOw=='),
		('pencil','R0lGODlhGAAYAKIHAAAAAP////b29kpKSvX19bGxsUlJSf///yH5BAEAAAcALAAAAAAYABgAAAM+eLrc/jDKSau9D2jMgBkGwClAEAzieJRoymkA4b5FIMyXJgR4Xuy9iiYgU61qN5VGFhTCjKsNVDqFWq/YSwIAOw=='),
		]
		
		i=0
		for tool in moreTools:
			im = PhotoImage(format='gif',data=tool[1])
			self.images[tool[0]] = im #store images in memory
			
			b = Button(frBottom, image=im, command=Callable(self.setTool,tool[0]))
			b.grid(row=i/2,column=i%2)
			self.dictButtons[tool[0]] = b
			i+=1
		
		self.setTool('design')

if __name__=='__main__':
	
	root = Tk()
	def onTest(root=root):
		se = ToolPallette()
		se.launch(root)
		se.draw_form()
	t = Button(root, text='Test', command=onTest)
	t.pack()
	t.mainloop()
